<template>
  <div>
    <!-- 底部部分 -->
    <footer class="footer">
      <span class="todo-count"
        >剩余<strong>{{ list.length }}</strong></span
      >
      <ul @click="$emit('changeType', type)" class="filters">
        <li>
          <a
            @click.prevent="type = 'all'"
            :class="{ selected: type === 'all' }"
            href="#/"
            >全部</a
          >
        </li>
        <li>
          <a
            @click.prevent="type = 'active'"
            :class="{ selected: type === 'active' }"
            href="#/active"
            >进行中</a
          >
        </li>
        <li>
          <a
            @click.prevent="type = 'completed'"
            :class="{ selected: type === 'completed' }"
            href="#/completed"
            >已完成</a
          >
        </li>
      </ul>
      <button @click="del" v-show="showClear" class="clear-completed">
        清除已完成
      </button>
    </footer>
  </div>
</template>

<script>
export default {
  name: "VuecliDayyiTodoFooter",

  data() {
    return {
      type: "all",
    };
  },
  props: {
    list: {
      typr: Array,
      required: true,
    },
  },
  computed: {
    showClear() {
      // 显示或者隐藏清空已完成
      return this.list.some((item) => item.isDone);
    },
  },
  methods: {
    del() {
      // 传值 清空
      this.$emit("delClear");
    },
  },
};
</script>

<style lang="scss" scoped>
</style>